<template>
  <div class="inside-page">
    <div class="choice-wrap">
      <div class="choice-wrap-container clearfix">
        <div
          class="wrap-left"
          :style="{
            background:
              'url(https://weilaixiaozhao.com/upload/'+ info.thumbnail +') center center / cover no-repeat',
          }"
        ></div>
        <div class="wrap-right">
          <p class="wrap-name">
            <span class="name" :title="info.post_title">{{ info.post_title }}</span>
          </p>
          <p class="pro">文章来源：{{ info.post_source == '' ? '无' : info.post_source }}</p>
          <div class="wrap">
            <p>
              <i class="iconfont icon-time"></i>
              <span>发布时间：{{ info.published_time }}</span>
            </p>
            <p>
              <i class="iconfont icon-hangye"></i>
              <span>点击量：{{ info.post_hits }}</span>
            </p>
            <p>
              <i class="iconfont icon-edit"></i>
              <span>文章关键词：{{ info.post_keywords == '' ? '无' : info.post_keywords }}</span>
            </p>
          </div>
          <div class="time">
            <p>
              <span>文章摘要：{{ info.post_excerpt == '' ? '无' : info.post_excerpt }}</span>
            </p>
          </div>
        </div>
      </div>
    </div>
    <div class="choice-detail content">
      <div class="intro-text">
        <div
          v-if="info.post_content"
          class="active"
          v-html="info.post_content"
        ></div>
      </div>
    </div>

  </div>
</template>

<script>
import {getNewsDetail} from '@/api/news';

export default {
  asyncData: ({ req }) => ({
  }),
  components: {},
  data () {
    return {
      info: {
        desc: ''
      }
    }
  },
  head () {
    return {
      titleTemplate: (titleChunk) => {
        return `${titleChunk} - 大学生找工作、找实习`;
      }
    }
  },
  created () {
    this.id = this.$route.query.id;
    this.fetchData();
  },
  mounted () {
  },
  watch: {

  },
  computed: {

  },
  methods: {
    async fetchData () {
      await getNewsDetail({
        id: this.id,
      }).then(res => {
        if (res.code === 200) {
          this.info = res.data;
        } else {
          this.$message.error(res.msg);
        }
      }).catch(err => {
        console.error(err)
        this.$message.error(err);
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.inside-page {
  width: 100%;
  position: relative;
  .choice-wrap {
    width: 100%;
    min-height: 220px;
    padding-top: 40px;
    padding-bottom: 40px;
    background: #f6f7f8;
    position: relative;
    .choice-wrap-container {
      width: $base-width;
      margin: 0 auto;
      position: relative;
      .wrap-left {
        float: left;
        height: 140px;
        width: 140px;
        overflow: hidden;
        background: #fff;
        border-radius: 8px;
        text-align: center;
        img {
          height: 140px;
        }
      }
      .wrap-right {
        float: left;
        margin-left: 20px;
        position: relative;
        width: 1000px;
        .wrap-name {
          line-height: 44px;
          .name {
            font-size: 28px;
            color: #24292f;
          }
          .corner {
            vertical-align: top;
            display: inline-block;
            margin-left: 5px;
            margin-top: 5px;
            width: 70px;
            height: 24px;
            line-height: 22px;
            font-size: 12px;
            text-align: center;
            border-radius: 4px;
            background: rgba(71, 113, 220, 0.3);
            color: $base-color;
            border: 1px solid $base-color;
            &.active {
              background: rgba(252, 112, 62, 0.3);
              color: $base-color-important;
              border: 1px solid $base-color-important;
            }
          }
        }
        .pro {
          margin: 10px 0;
          font-size: 14px;
          color: #999;
        }
        .wrap {
          p {
            margin-right: 30px;
            display: inline-block;
            line-height: 20px;
            vertical-align: middle;
            i {
              color: $base-color;
              font-size: 16px;
              vertical-align: middle;
            }
            span {
              vertical-align: middle;
              font-size: 14px;
              color: #666;
            }
          }
          .money {
            i,
            span {
              color: $base-color-danger;
              font-size: 14px;
              line-height: 20px;
            }
            i {
              font-size: 16px;
            }
          }
        }
        .time {
          padding-left: 15px;
          margin-top: 10px;
          position: relative;
          height: 20px;
          line-height: 20px;
          i,
          span {
            margin-right: 10px;
            font-size: 14px;
            color: #666;
          }
          &::before {
            content: '';
            height: 14px;
            width: 2px;
            background: $base-color;
            position: absolute;
            left: 2px;
            top: 3px;
          }
        }
      }
      .company-data {
        position: absolute;
        right: 0;
        top: 35%;
        transform: translateY(-20%);
        .data {
          float: left;
          text-align: center;
          padding-left: 15px;
          &:first-child {
            padding-left: 0;
          }
          .num {
            font-size: 28px;
            color: $base-color;
          }
          .text {
            font-size: 14px;
            color: #999;
          }
        }
        .submit {
          margin-top: 80px;
          button {
            width: 190px;
          }
          .disabled {
            display: inline-block;
            height: 45px;
            line-height: 43px;
            width: 150px;
            margin: 0 20px;
            border: 1px solid #ccc;
            border-radius: 6px;
            font-size: 16px;
            background: #ccc;
            color: #f1f1f1;
            cursor: not-allowed;
          }
        }
      }
    }
  }

  .choice-detail {
    position: relative;
    .intro {
      height: 280px;
      background: #ebebeb;
    }
    .intro-text {
      position: relative;
      padding: 20px 0;
      p {
        font-size: 16px;
        line-height: 32px;
      }
      .con {
        font-size: 16px;
        line-height: 22px;
        color: #666;
        white-space: pre-wrap;
        height: 44px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        &.active {
          height: auto;
          overflow: visible;
          text-overflow: clip;
          word-break: break-all;
          word-wrap: break-word;
          white-space: normal;
          -webkit-line-clamp: inherit;
        }
      }
      .toggle-btn {
        position: absolute;
        right: 0;
        bottom: -5px;
        color: $base-color;
        font-size: 14px;
        &:hover {
          cursor: pointer;
          color: $base-color-hover;
        }
      }
    }
    .pos-filter {
      height: 50px;
      line-height: 40px;
      padding-top: 10px;
      p {
        float: left;
      }
      ::v-deep .el-input__inner {
        height: 30px;
        line-height: 30px;
      }
    }
  }

  .choice-list {
    margin: 20px auto;
    .choice-item {
      height: 120px;
      width: 100%;
      border: 1px solid #ebebeb;
      background: #fff;
      margin-bottom: 10px;
      padding-left: 40px;
      cursor: pointer;
      &:hover {
        background: #f6f7f8;
      }
      & > div {
        float: left;
      }
      .choice-pos {
        margin-top: 30px;
        line-height: 30px;
        margin-right: 20px;
        min-width: 300px;
        .choice-name {
          color: #242924;
          font-size: 18px;
          display: inline-block;
          max-width: 300px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .wrap {
          p {
            margin-right: 10px;
            color: #999;
            line-height: 20px;
            font-size: 14px;
            display: inline-block;
          }
          i {
            vertical-align: middle;
            color: #999;
            margin-right: 5px;
          }
          span {
            vertical-align: middle;
            color: #999;
          }
        }
      }
      .choice-type {
        margin-top: 30px;
        width: 210px;
        line-height: 30px;
        overflow: hidden;
        .name {
          font-size: 14px;
          color: #999;
        }
        .text {
          margin-top: 10px;
          white-space: nowrap;
          overflow: hidden;
          .tag {
            display: inline-block;
            min-width: 66px;
            height: 24px;
            line-height: 22px;
            font-size: 12px;
            color: #ccc;
            text-align: center;
            border: 1px solid #ebebeb;
            border-radius: 4px;
            margin-right: 6px;
          }
        }
      }
      .choice-num {
        margin-top: 30px;
        text-align: center;
        .num {
          color: $base-color;
          font-size: 28px;
        }
        .none {
          color: #999;
          font-size: 28px;
        }
        .text {
          font-size: 12px;
          color: #999;
        }
      }
      .choice-job {
        margin-top: 30px;
        width: 300px;
        line-height: 30px;
        .pos {
          span {
            margin-right: 20px;
            color: #666;
            font-size: 18px;
          }
        }
        .time {
          margin-top: 10px;
          i,
          span {
            color: #999;
            font-size: 14px;
          }
        }
      }
      .choice-logo {
        margin-top: 24px;
        margin-right: 24px;
        width: 74px;
        height: 74px;
        overflow: hidden;
        float: right;
      }
    }
  }
}
</style>
